import { createTablePopper } from 'element-plus/es/components/table/src/util.mjs';
import { request,requestGet } from './axios.js';

const createApiMethod = (url) => {
    return (params) => request(url, 'POST', { ...params });
};

// 登录接口
export const authApi = {
    login: createApiMethod('/login'), // 登录
};

// 馆藏地接口
export const libraryLocationApi = {
    getLibraryLocationList: createApiMethod('/libraryLocation/list'),  // 获取馆藏地列表
    addLibraryLocation: createApiMethod('/libraryLocation/add'),      // 新增馆藏地
    updateLibraryLocation: createApiMethod('/libraryLocation/update'), // 更新馆藏地信息
    deleteLibraryLocation: createApiMethod('/libraryLocation/delete'), // 删除馆藏地
};

// 用户接口
export const userApi = {
    getUserList: createApiMethod('/user/list'), // 获取用户列表/根据user_id获取某个用户的信息
    addUser: createApiMethod('/user/add'), // 新增用户
    updateUser: createApiMethod('/user/update'), // 更新用户信息
    deleteUser: createApiMethod('/user/delete'), // 删除用户
};

// 期刊接口
export const journalApi = {
    getJournalList: createApiMethod('/journals/list'), // 获取期刊列表
    addJournal: createApiMethod('/journals/add'), // 新增期刊
    updateJournal: createApiMethod('/journals/update'), // 更新期刊信息
    deleteJournal: createApiMethod('/journals/delete'), // 删除期刊
};

// 目录接口
export const journalDirectoryApi = {
    getDirectoryList: createApiMethod('/directories/list'), // 获取目录列表
    addDirectory: createApiMethod('/directories/add'), // 新增目录
    updateDirectory: createApiMethod('/directories/update'), // 更新目录信息
    deleteDirectory: createApiMethod('/directories/delete'), // 删除目录
};

// 借阅接口
export const borrowApi = {
    addBorrowRecord: createApiMethod('/borrow/add'), // 新增借阅记录
    getBorrowList: createApiMethod('/borrow/list'), // 查询借阅记录
    deleteBorrowRecord: createApiMethod('/borrow/delete'), // 删除借阅记录
    updateBorrowStatus: createApiMethod('/borrow/update-status'), // 修改借阅状态
};

// 委托接口
export const entrustmentApi = {
    addEntrustment: createApiMethod('/entrustments/add'), // 新增委托申请
    getEntrustmentList: createApiMethod('/entrustments/list'), // 查询委托申请列表
    updateEntrustmentStatus: createApiMethod('/entrustments/update-status'), // 管理员审批或拒绝委托
    deleteEntrustmentStatus: createApiMethod('/entrustments/delete'), // 管理员审批或拒绝委托
};

// 罚款记录接口
export const finesApi = {
    getFinesList: createApiMethod('/fines/list'), // 查询罚款记录
    updateFineStatus: createApiMethod('/fines/update'), // 修改罚款记录状态并恢复借阅状态
    deleteFineRecord: createApiMethod('/fines/delete'), // 删除罚款记录
};

// 反馈接口
export const feedbackApi = {
    getFeedbackList: createApiMethod('/feedback/list'),    // 获取反馈列表
    submitFeedback: createApiMethod('/feedback/submit'),    // 提交反馈
    replyFeedback: createApiMethod('/feedback/reply'),    // 管理员回复反馈
    deleteFeedback: createApiMethod('/feedback/delete')    // 删除反馈
};

// 年度征订接口
export const nextYearReservationApi = {
    getReservationList: createApiMethod('/nextYearReservations/list'), // 获取年度征订列表
    deleteReservation: createApiMethod('/nextYearReservations/delete'), // 删除年度征订记录
    addReservation: createApiMethod('/nextYearReservations/add'), // 新增年度征订记录
};

//常量设置接口
export const setApi = {
    updateFine: createApiMethod('/set/updateFine'),
    updateLockDay: createApiMethod('/set/updateLockDay'),
    updateNumofMagazine: createApiMethod('/set/updateNumOfMagzine'),
    updateStudentBorrowLimits: createApiMethod('set/updateStudentBorrowLimits'),
    updateTeacherBorrowLimits: createApiMethod('set/updateTeacherBorrowLimits'),
    getSettings: (params) => requestGet('set/getSettings', params) 
};